﻿using System;
using System.Web.UI;
using BLL;

public partial class ProductPCBAging_ManagePCBAging_PCBAgingInBox : System.Web.UI.Page
{
    //private static decimal inBoxU, inBoxI;
    private PCBAging ag;
    private string pCBAgingID
    {
        get
        {
            return ViewState["PCBAgingID"].ToString();
        }
        set
        {
            ViewState["PCBAgingID"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["PCBAgingID"] != null)
            {
                pCBAgingID = Request.QueryString["PCBAgingID"];
                this.TextBox1.Text = pCBAgingID;
                BindPCBAging(pCBAgingID);
            }
        }
    }

    public ProductPCBAging_ManagePCBAging_PCBAgingInBox()
    {
        ag = new PCBAging();
    }

    protected void BindPCBAging(string pCBAgingID)
    {
        UserControl_PCBAging uc = (UserControl_PCBAging)LoadControl("~/UserControl/PCBAging.ascx");
        uc.pCBAgingID = pCBAgingID;
        this.PlaceHolder1.Controls.Add(uc);
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        pCBAgingID = this.TextBox1.Text.Trim();
        if (!ag.PCBAging_ExistsID(pCBAgingID))
        {
            string str1 = "此批次号不存在，或者没有相关的进箱信息，请确认！";
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", "<script>alert('" + str1 + "');</script>", false);
        }
        else
        {
            BindPCBAging(pCBAgingID);
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {
            decimal inBoxU = decimal.Parse(this.TextBox2.Text.Trim());
            decimal inBoxI = decimal.Parse(this.TextBox3.Text.Trim());
            string userID = User.Identity.Name;
            string str;
            if (ag.PCBAging_InBox(pCBAgingID, userID, inBoxU, inBoxI))
                str = "确认成功！";
            else
                str = "确认失败！请联系管理员。";
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", "<script>alert('" + str + "');</script>", false);
            BindPCBAging(pCBAgingID);
        }
        catch(FormatException)
        {
            string str1 = "输入电压、电流数据的格式不对！";
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", "<script>alert('" + str1 + "');</script>", false);
        }
    }
}
